<template>
  <div class="div" ref="div">
    
  </div>
</template>

<script setup>
import * as echarts from 'echarts'
import {onMounted,ref,reactive} from 'vue'
import {getelectricity} from '../../request/index'

const option=reactive({
  grid:null,
  xAxis:null,
  yAxis:null,
  series:null
})
const div=ref()
let myChart 
onMounted(()=>{
  getelectricity().then(res=>{
     myChart=echarts.init(div.value)
     console.log('实时用电',res.data.data);
     option.grid=res.data.data.grid
     option.series=res.data.data.series
     option.xAxis=res.data.data.xAxis
     option.yAxis=res.data.data.yAxis
    myChart.setOption(option)
  })
   


})
  window.addEventListener('resize', function() {
    myChart.resize();
  });


</script>

<style scoped>
.div{
    width: 99%;
    height: 70%;
}
</style>